package com.sixmac.controller;

import com.sixmac.common.base.BaseController;
import com.sixmac.core.annotation.Validator;
import com.sixmac.core.base.model.Format;
import com.sixmac.core.toolbox.ajax.AjaxResult;
import com.sixmac.platform.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by admin on 2018/9/5.
 */
@Controller
@RequestMapping("/login")
@ResponseBody
public class LoginController extends BaseController {
    @Autowired
    LoginService loginService;

    /**
     * @api {post} /login/login 0.1登录
     * @apiName login.login
     * @apiGroup login
     * @apiParam {String} account 账号
     * @apiParam {String} password 密码
     * @apiSuccess {String} user.id 安装员id
     * @apiSuccess {String} user.token token
     * @apiSuccess {String} user.name 名称
     * @apiSuccess {String} user.sex 性别 1男2女
     */
    @RequestMapping("/login")
    @Validator(name = {"account", "password"}, format = {Format.NOT_NULL, Format.NOT_NULL})
    public AjaxResult login(String account, String password) {
        return loginService.login(account, password);
    }
}
